#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<assert.h>
#include<stdlib.h>

char* my_strncpy(char* dest, const char* src, size_t num)
{
	assert(dest&&src);
	char* ret = dest;
	while (num-- && (*dest++ = *src++))
		;
	return ret;
}


char* my_strncat(char* dest, char* src, size_t num)
{
	char* ret = dest;
	while (*dest)
		++dest;
	while (num-- && (*dest++ = *src++))
		;
	*dest = '\0';
}

int my_atoi(const char* str)
{
	int ret = 0;
	int flag = 1;
	while (*str == ' ')
		str++;
	if (*str++ == '-')
		flag = -1;
	else if (*str < '0' || *str>'9')
		return 0;

	while (*str >= '0' && *str <= '9')
	{
		ret += *str - '0';
		if (*(str + 1) >= '0' && *(str + 1) <= '9')
			ret *= 10;
		++str;
	}
	return ret * flag;
}

int main()
{
	char str1[] = "  -76yy";
	char str2[] = "world";
	//strncpy(str1, str2 , strlen(str2));
	//my_strncpy(str1, str2, 4);
	//my_strncat(str1, str2, strlen(str2) - 1);
	//puts(str1);
	printf("%d", my_atoi(str1));
	return 0;
}